/**
 * Component.h
 * Coyright (c) 2009 Xiaofeng Gu. All Rights Reserved.
 * Author : Xiaofeng Gu
 *
 * Creation Data : 2009/06/11
 */

#pragma once

#include <vector>
#include "TransNode.h"
#include "Path.h"
#include "IGraphics.h"
#include "SKObject.h"

class CComponent;
typedef std::vector<CTransNode*> Nodes;
typedef std::vector<NodeDifference*> Diffs;
typedef std::vector<CComponent*> Components;

class CFamily;

class CComponent : public CSKObject
{
public:
	CComponent(CFamily* pParent);
	virtual ~CComponent();

	virtual bool		OnRead(CXMLParser* pParser);
	virtual bool		OnWrite(CXMLParser* pParser);

// operator
	CTransPath*			operator-(CComponent& Component);

// method
	virtual void		Render();
	virtual CGBox&		GetRangeBox();
	virtual void		HighLight(bool bHighLight);

public:
	CComponent*			Copy();

	virtual void		Back();
	virtual void		Rollback();

// property
	Nodes*				GetNodes()
	{ return &m_Nodes; }

	CTransNode*			GetTopNode();
	void				SetTopNode(CTransNode* pNode)
	{ m_pTopNode = pNode; }

	CTransPath*			GetPath()
	{ return m_pPath; }

	Diffs*				GetDiffs()
	{ return &m_Diffs; }

	void				SetTime(long time)
	{ m_Time = time; }
	long				GetTime()
	{ return m_Time; }

	void				SetRange(CVec& min, CVec& max)
	{ m_min = min; m_max = max; }

	virtual SKObjectType GetSKObjectType()
	{ return eComponent; }

	CFamily*			GetParent() { return m_pParent; }

	virtual void		SetActive(bool bActive);

	virtual void		UpdateExpandStatus(CTreeCtrl* pTree);

	virtual void		Expand(CTreeCtrl* pTree);

	virtual CString		GetName() { return m_strComponentName; }

private:
	CVec				m_min;
	CVec				m_max;
	CTransNode*			m_pTopNode;
	CFamily*			m_pParent;

private:
	CTransPath*			m_pPath;
	Diffs				m_Diffs;

// the attributes to be read and writed
private:
	long				m_Time;
	bool				m_bHightLight;
	Nodes				m_Nodes;
	CString				m_strComponentName;
};